package double_pointer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-12-02
 * Time: 16:55
 */
public class RemoveDuplicates {
    public static int removeDuplicates(int[] nums) {
        int fast = 1;
        int low = 0;
        int k = 1;
        while (fast < nums.length) {
            if(nums[fast] != nums[fast - 1]) {
                low++;
                nums[low] = nums[fast];
                k++;
            }
            fast++;
        }
        return k;
    }

    public static void main(String[] args) {
        System.out.println(removeDuplicates(new int[]{1, 1, 1}));
    }
}
